<?php
/** @var TbActiveForm $form */
/** @var Node $model */
?>
<div class="text-right">
	<button type="button" class="btn" data-toggle="collapse" data-target="#filter-form">
		筛选
	</button>
</div>
<div class="filter-form collapse out <?php echo isset($_GET['filter']) ? 'in' : ''; ?>" id="filter-form">
	<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
		'action' => Yii::app()->createUrl($this->route, array('channel_id' => $channel->id)),
		'method' => 'get',
		'type' => 'horizontal',
	));
	?>

	<?php
	$this->widget('YTaxonomyFilterWidget', array(
		'model' => $model,
	));
	?>

	<?php echo $form->dropDownListRow($model, 'status', $model->getStatusList(), array('empty' => '', 'class' => 'span1')); ?>

	<?php echo $form->dropDownListRow($model, 'sticky', array('否', '是'), array('empty' => '', 'class' => 'span1')); ?>

	<?php echo $form->dropDownListRow($model, 'promote', array('否', '是'), array('empty' => '', 'class' => 'span1')); ?>

	<div class="text-right">
		<?php echo CHtml::submitButton('筛选', array('name' => 'filter', 'class' => 'btn btn-primary')); ?>
	</div>
	<?php $this->endWidget(); ?>
</div>
<?php ?>
<?php if (isset($_GET['filter'])): ?>
	<h3>筛选结果：
		<small><?php echo CHtml::link('重置', array($this->route, 'channel_id' => $channel->id)); ?></small>
	</h3>
<?php endif; ?>
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'type' => 'horizontal',
));
$actions = array(
	'' => '批量操作',
	'sticky' => '置顶',
	'unsticky' => '取消置顶',
	'promote' => '显示在首页',
	'demote' => '取消显示在首页',
	'public' => '公开',
	'draft' => '草稿',
	'delete' => '删除',
);?>
<?php $this->widget('bootstrap.widgets.TbExtendedGridView', array(
	'id' => strtolower(get_class($this)) . '-grid',
	'dataProvider' => $model->search(),
	'filter' => $model,
	'bulkActions' => array(
		'class' => 'YBulkActions',
		'align' => 'left',
		'actionButtons' => $actions,
	),
	'columns' => array(
		array(
			'name' => 'id',
			'class' => 'CCheckBoxColumn',
			'selectableRows' => 2,
			'checkBoxHtmlOptions' => array('name' => 'ids[]'),
		),
		/*
		array(
			'name' => 'id',
			'headerHtmlOptions' => array('class' => 'id-column'),
		),
		*/
		array(
			'name' => 'title',
			'type' => 'raw',
			'value' => '$data->getRawTitle()',
		),
		array(
			'name' => 'status',
			'class' => 'YStatusColumn',
			'statusList' => $model->getStatusList(),
			'labelMap' => array(
				Node::STATUS_DRAFT => YStatusColumn::LABEL_WARNING,
				Node::STATUS_PUBLIC => YStatusColumn::LABEL_SUCCESS,
			),
			'filter' => $model->getStatusList(),
		),
		array(
			'name' => 'create_time',
			'class' => 'YDatetimeColumn',
			'type' => 'date',
			'filter' => YUtil::timeFilterList(),
		),
		array(
			'class' => 'YContentButtonColumn',
			'channel' => $channel,
		),
	),
)); ?>
<?php $this->endWidget(); ?>
